#include <tile.h>


int CTile::get_ForeColor( int y )
{
	return m_ForeColors[y];
}

int CTile::get_BgColor( int y )
{
	return m_BgColors[y];
}

int CTile::get_Pixel( int x, int y )
{
	return m_Pixels[x][y];
}

void CTile::put_ForeColor( int y, int color )
{
	m_ForeColors[y] = color;
}

void CTile::put_BgColor( int y, int color )
{
	m_BgColors[y] = color;
}

void CTile::put_Pixel( int x, int y, int color )
{
	m_Pixels[x][y] = color;
}


CTile::CTile()
{
	int x, y;
	
	for( y = 0; y < 8; y++ ) 
	{
		m_BgColors[y] = 1;
		m_ForeColors[y] = 1;
		
		for( x = 0; x < 8; x++ ) 
		{
			m_Pixels[x][y] = 0;
		}
	}
}


int CTile::GetPixelColor( int x, int y )
{
	if( m_Pixels[x][y] == 1 ) return m_ForeColors[y];
	
	return m_BgColors[y];
}

void CTile::SetBackColor( int y, int color )
{
	m_BgColors[y] = color;
}

void CTile::SetForeColor( int y, int color )
{
	m_ForeColors[y] = color;
}

int CTile::GetForeColor( int y )
{
	return m_ForeColors[y];
}

int CTile::GetBgColor( int y )
{
	return m_BgColors[y];
}

void CTile::SetBackPixel( int x, int y )
{
	m_Pixels[x][y] = 0;
}

void CTile::SetForePixel( int x, int y )
{
	m_Pixels[x][y] = 1;
}

int CTile::GetRowPattern( int row )
{
	int i;
	int value;
	
	value = 0;
	for( i = 7; i >=0; i-- )
	{
		value = value | ( m_Pixels[7-i][row] << i );
	}
	return value;
}

int CTile::GetRowColor( int row )
{
	return ( m_ForeColors[row]<<4 ) | m_BgColors[row];
}